import React from 'react';
import { Checkbox } from 'antd';

const useNoLabourPeriod = ({ applyData, form, formItemId }) => {
    const isNoLabourPeriod = (form?.getFieldValue(formItemId) || applyData?.labourPeriodNumber) === -1;

    const handleLabourChange = e => {
        const nextValue = e.target.checked ? -1 : 3;
        return form?.setFieldsValue({ [formItemId]: nextValue });
    };

    const noLabourPeriodCheckbox = (
        <Checkbox checked={isNoLabourPeriod} onChange={handleLabourChange}>
            无固定期限
        </Checkbox>
    );

    const noLabourPeriodText = '无固定期限';

    return {
        isNoLabourPeriod,
        noLabourPeriodCheckbox,
        noLabourPeriodText
    };
};

export default useNoLabourPeriod;
